package org.dizem.freepl0.compiler.symbol;

/**
 * Created by IntelliJ IDEA.
 * User: DIZEM
 * Date: 11-2-1
 * Time: 下午9:47
 */
public enum Symbol {
	NUL, IDENT, NUMBER, PLUS, MINUS, TIMES,
	SLASH, ODDSYM, EQL, NEQ, LSS, LEQ, GTR, GEQ, LPAREN, RPAREN,
	COMMA, SEMICOLON, PERIOD, BECOMES, BEGINSYM, ENDSYM,
	IFSYM, THENSYM, ELSESYM, WHILESYM, REPEATSYM,
	UNTILSYM, WRITESYM, READSYM, DOSYM, CALLSYM, CONSTSYM,
	VARSYM, PROCSYM, LASTSYM, ENDFILE;

	public static Symbol find(String s) {
		s = s.toLowerCase();
		if(s.equals("begin")) return Symbol.BEGINSYM;
		if(s.equals("call")) return Symbol.CALLSYM;
		if(s.equals("const")) return Symbol.CONSTSYM;
		if(s.equals("do")) return Symbol.DOSYM;
		if(s.equals("end")) return Symbol.ENDSYM;
		if(s.equals("if")) return Symbol.IFSYM;
		if(s.equals("odd")) return Symbol.ODDSYM;
		if(s.equals("procedure")) return Symbol.PROCSYM;
		if(s.equals("read")) return Symbol.READSYM;
		if(s.equals("then")) return Symbol.THENSYM;
		if(s.equals("var")) return Symbol.VARSYM;
		if(s.equals("while")) return Symbol.WHILESYM;
		if(s.equals("write")) return Symbol.WRITESYM;
		if(s.equals("else")) return Symbol.ELSESYM;
		if(s.equals("repeat")) return Symbol.REPEATSYM;
		if(s.equals("until")) return Symbol.UNTILSYM;
		return Symbol.IDENT;
	}

};